/**
 * 
 */
package com.xintoucloud.gsv.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.xintoucloud.gsv.entity.Dept;
import com.xintoucloud.gsv.model.TreeNode;

/**
 * @author xiang
 *
 */
public interface DeptMapper {
	
	//查询所有部门
	@Select("select * from t_dept")
	List<Dept> listDept();
	
	/**
	 * 查询parentId为0的组织集合
	 * @return
	 */
	@Select("select * from t_dept where parentId=0")
	List<Dept> listDeptIsZeroParentId();
	/**
	 * 根据parentId查询其所有组织集合
	 * @param parentId
	 * @return
	 */
	@Select("select * from t_dept where parentId=#{parentId}")
	List<Dept> listDeptByParentId(Integer parentId);
	
	/**
	 * 根据oId查询其详细信息
	 * @param parentId
	 * @return
	 */
	@Select("select * from t_dept where did=#{did}")
	Dept getOne(Integer did);
	
	@Select("select * from t_dept where did=#{did}")
	Dept getDept(@Param("did")int did);
	
	@Insert("insert into t_dept(dname,address,Leader_id,cmleader_id,parentId) values(#{dname},#{address},#{Leader_id},#{cmleader_id},#{parentId})")
	void saveDept(Dept dept);
	
	@Delete("delete from t_dept where did=#{did}")
	void deleteDept(int did);
	
	@Update("update t_dept set dname=#{param2} where did=#{param1}")
	void updateOrganization(int did,String dname);
	
	

}
